package com.example.gzysmartcity.ui.adapter;

import android.util.Log;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.gzysmartcity.R;

import org.jetbrains.annotations.NotNull;

public class BusContentAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    private final int size;

    public BusContentAdapter(int layoutResId, int size) {
        super(layoutResId);
        this.size = size;
        Log.i("TAG", "BusContentAdapter: ");
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, String string) {
        ImageView imageView = baseViewHolder.getView(R.id.image_busline);
        int position = baseViewHolder.getAdapterPosition();
        if (position == 0) {
            Glide.with(getContext()).load(R.mipmap.line1).into(imageView);
        } else if (position == size - 1) {
            Glide.with(getContext()).load(R.mipmap.line3).into(imageView);
        } else {
            Glide.with(getContext()).load(R.mipmap.line2).into(imageView);
        }
        baseViewHolder.setText(R.id.tv_rv_busline, string);
    }
}
